/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.giant.authentication;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Harold
 */
@Entity
@Table(name = "access")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Access.findAll", query = "SELECT a FROM Access a"),
    @NamedQuery(name = "Access.findByIdAccess", query = "SELECT a FROM Access a WHERE a.idAccess = :idAccess"),
    @NamedQuery(name = "Access.findByCodFunc", query = "SELECT a FROM Access a WHERE a.codFunc = :codFunc"),
    @NamedQuery(name = "Access.findByIsFunction", query = "SELECT a FROM Access a WHERE a.isFunction = :isFunction"),
    @NamedQuery(name = "Access.findByLabel", query = "SELECT a FROM Access a WHERE a.label = :label"),
    @NamedQuery(name = "Access.findByStatus", query = "SELECT a FROM Access a WHERE a.status = :status")})
public class Access implements Serializable {
    @JoinTable(name = "profile_access", joinColumns = {
        @JoinColumn(name = "id_access", referencedColumnName = "id_access")}, inverseJoinColumns = {
        @JoinColumn(name = "id_profile", referencedColumnName = "id_profile")})
    @ManyToMany
    private Collection<Profile> profileCollection;
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id_access")
    private Integer idAccess;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 32)
    @Column(name = "cod_func")
    private String codFunc;
    @Basic(optional = false)
    @NotNull
    @Column(name = "is_function")
    private boolean isFunction;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 128)
    @Column(name = "label")
    private String label;
    @Basic(optional = false)
    @NotNull
    @Column(name = "status")
    private boolean status;
    @JoinColumn(name = "id_module", referencedColumnName = "id_module")
    @ManyToOne(optional = false)
    private Module idModule;

    public Access() {
    }

    public Access(Integer idAccess) {
        this.idAccess = idAccess;
    }

    public Access(Integer idAccess, String codFunc, boolean isFunction, String label, boolean status) {
        this.idAccess = idAccess;
        this.codFunc = codFunc;
        this.isFunction = isFunction;
        this.label = label;
        this.status = status;
    }

    public Integer getIdAccess() {
        return idAccess;
    }

    public void setIdAccess(Integer idAccess) {
        this.idAccess = idAccess;
    }

    public String getCodFunc() {
        return codFunc;
    }

    public void setCodFunc(String codFunc) {
        this.codFunc = codFunc;
    }

    public boolean getIsFunction() {
        return isFunction;
    }

    public void setIsFunction(boolean isFunction) {
        this.isFunction = isFunction;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public boolean getStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    public Module getIdModule() {
        return idModule;
    }

    public void setIdModule(Module idModule) {
        this.idModule = idModule;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idAccess != null ? idAccess.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Access)) {
            return false;
        }
        Access other = (Access) object;
        if ((this.idAccess == null && other.idAccess != null) || (this.idAccess != null && !this.idAccess.equals(other.idAccess))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.giant.authentication.Access[ idAccess=" + idAccess + " ]";
    }

    @XmlTransient
    public Collection<Profile> getProfileCollection() {
        return profileCollection;
    }

    public void setProfileCollection(Collection<Profile> profileCollection) {
        this.profileCollection = profileCollection;
    }
    
}
